package fast.main.service.impl;

import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import fast.main.mapper.BaseMapper;
import fast.main.service.BaseService;

@Service
@Transactional
public class BaseServiceImpl implements BaseService{
	
	@Autowired
	BaseMapper mapper;

	@Override
	public List<Map<String, Object>> query(String sql) {
		if(mapper==null){
			System.out.println("mapper为空。。。。。。。。。。。。");
		}
		return mapper.query(sql);
	}
	
	@Override
	public List<Map<String, Object>> query(String sql,String pageNo,String pageSize) {
		if(mapper==null){
			System.out.println("mapper为空。。。。。。。。。。。。");
		}
		sql="SELECT * FROM ( SELECT A.*, ROWNUM RN FROM ("+sql+") A WHERE ROWNUM <= "+pageNo+"*"+pageSize+" ) WHERE RN > ("+pageNo+"-1)*"+pageSize;
		return mapper.query(sql);
	}
	
	@Override
	public int queryCount(String sql) {
		return mapper.queryCount(sql);
	}
	
	@Override
	public Integer insert(String sql) {
		return mapper.insert(sql);
	}

	@Override
	public Integer delete(String sql) {
		return mapper.delete(sql);
	}

	@Override
	public Integer update(String sql) {
		return mapper.update(sql);
	}

	@Override
	public List<Map<String, Object>> callByKey(String key) {
		return mapper.call(key);
	}


}
